{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "f38cc69f",
   "metadata": {},
   "source": [
    "### 一、从列表中删除对象"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "eb8535d5",
   "metadata": {},
   "source": [
    "#### 1.remove: 取一个对象作为唯一参数"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "b3b0f4a7",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "[1, 2, 3, 4]"
      ]
     },
     "execution_count": 1,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    ">>> nums = [1,2,3,4]\n",
    ">>> nums"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "2b54d022",
   "metadata": {},
   "source": [
    "#### 2. 调用remove后，值为3的对象会消失"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "e706a5e5",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "[1, 2, 4]"
      ]
     },
     "execution_count": 2,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    ">>> nums.remove(3)\n",
    ">>> nums"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "0e3543bb",
   "metadata": {},
   "source": [
    "### 二、从列表中弹出对象"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "03fec702",
   "metadata": {},
   "source": [
    "#### 1.pop:取一个可选的索引值作为参数"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "id": "a7da96fa",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "4"
      ]
     },
     "execution_count": 4,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    ">>> nums.pop()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "id": "3b23019e",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "[1, 2]"
      ]
     },
     "execution_count": 5,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    ">>> nums"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "id": "249a63e7",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "1"
      ]
     },
     "execution_count": 6,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    ">>> nums.pop(0)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "id": "7f208864",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "[2]"
      ]
     },
     "execution_count": 7,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    ">>> nums"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "6b80f557",
   "metadata": {},
   "source": [
    "### 三、在列表中插入一个对象"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "2c6a93df",
   "metadata": {},
   "source": [
    "#### 1.取一个索引值和一个对象作为参数"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "id": "915ec82a",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "[1, 2]"
      ]
     },
     "execution_count": 8,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    ">>> nums.insert(0,1)\n",
    ">>> nums"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "id": "e31794b4",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "[1, 2, 'two-and-a half']"
      ]
     },
     "execution_count": 9,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    ">>> nums.insert(2,\"two-and-a half\")\n",
    ">>> nums"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "49b75ee1",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "224f7102",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "d251d798",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "9337f0fd",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.8.8"
  },
  "toc": {
   "base_numbering": 1,
   "nav_menu": {},
   "number_sections": true,
   "sideBar": true,
   "skip_h1_title": false,
   "title_cell": "Table of Contents",
   "title_sidebar": "Contents",
   "toc_cell": false,
   "toc_position": {},
   "toc_section_display": true,
   "toc_window_display": false
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
